#ifndef __GLF_TASK_TASKCONDITION_INCLUDED__
#define __GLF_TASK_TASKCONDITION_INCLUDED__

#include <glf/core/condition.h>
#include <list>

namespace glf {

class TaskManager;

class TaskCondition : NonCopyable
{
public:

	TaskCondition();
	virtual ~TaskCondition();

	bool Signal();
	void Wait();
	void Stop();

	void AddTaskManager(TaskManager* tm);
	void RemoveTaskManager(TaskManager* tm);

private:

	bool m_IsActive;
	bool m_IsWaiting;
	Mutex m_Mutex;
	Condition m_Condition;
	int64 m_WakeUpTime;
	int64 m_MinimalRunLength;

	typedef std::list<TaskManager*> TaskManagerList;
	TaskManagerList m_TaskManagerList;
};

} // end namespace glf

#endif // __GLF_TASK_TASKCONDITION_INCLUDED__
